import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

export default defineConfig({
  plugins: [
    vue()
  ],
  root: 'src',
  base: './',
  publicDir: '../public',
  build: {
    outDir: '../dist/renderer',
    emptyOutDir: true,
    rollupOptions: {
      input: {
        main: resolve(__dirname, 'src/index.html')
      }
    }
  },
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src')
    }
  },
  server: {
    port: 5173,
    proxy: {
      '/backend-api': {
        target: 'http://172.16.19.0:8000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/backend-api/, '/api')
      },
      '/sse-api': {
        target: 'http://localhost:5100',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/sse-api/, '/sse')
      }
    }
  }
})

